package com.androway.domains;

import java.io.Serializable;

import com.google.gson.annotations.Expose;

public final class Permission implements Serializable
{
	private static final long	serialVersionUID		= 1L;

	public static final int		ALL						= -1;

	public static final int		GET						= 1;
	public static final int		POST					= 2;
	public static final int		PUT						= 4;
	public static final int		DELETE					= 8;

	public static final int		COURSE_OTHER			= 16;

	public static final int		MARK_OTHER				= 16;

	public static final int		TIG_SET_AND_VALIDATE	= 16;

	public static final int		TYPE_FOLLOWABLE			= 1;
	public static final int		TYPE_REGISTRABLE		= 2;
	public static final int		TYPE_TEACHER			= 4;
	public static final int		TYPE_AER				= 8;
	public static final int		TYPE_EPITECH			= 16;

	public static final int		SCHOOL_GET_ALL			= 16;

	public static final int		USER_LOG_AS				= 16;

	@Expose
	private String				name;
	@Expose
	private int					value;
	private Group				group;

	public String getName()
	{
		return this.name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public int getValue()
	{
		return this.value;
	}

	public void setValue(int value)
	{
		this.value = value;
	}

	public Group getGroup()
	{
		return this.group;
	}

	public void setGroup(Group group)
	{
		this.group = group;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.group == null) ? 0 : this.group.hashCode());
		result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (this.getClass() != obj.getClass())
			return false;
		Permission other = (Permission) obj;
		if (this.group == null)
		{
			if (other.group != null)
				return false;
		}
		else if (!this.group.equals(other.group))
			return false;
		if (this.name == null)
		{
			if (other.name != null)
				return false;
		}
		else if (!this.name.equals(other.name))
			return false;
		return true;
	}

}
